package com.zhdl.modules.process;

import com.zhdl.common.ytools.springContext.impl.S7ParamOptImpl;
import com.zhdl.hardware_contact.hardware_config.entity.ProjectConfiguration;
import com.zhdl.modules.common.logging.service.OptRecordService;
import com.zhdl.modules.demo.aoptest.OptLog;
import com.zhdl.modules.demo.entity.MachineConf;
import com.zhdl.modules.demo.testprocess.TestMainProcess;
import com.zhdl.modules.process.service.ProjectConfigProcessService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 此类持有项目主流程管理类 外部通过此类控制主流程 开始 暂停 急停等操作
 */
@Service
public class PLCStatusExchangeHolder {
    @Resource
    S7ParamOptImpl s7ParamOpt;

    @Resource
    OptRecordService optRecordService;
    @Resource
    ProjectConfigProcessService projectConfigProcessService;

    @OptLog(title = "开机初始化")
    public void init(){

    }


    @OptLog(title = "初始化位置")
    public void initLocation(){
        s7ParamOpt.paramOpt(projectConfigProcessService.getValue("初始化"),"");
    }
    @OptLog(title = "程序启动")
    public void start(){
        optRecordService.saveRecords("程序启动");
        s7ParamOpt.paramOpt(projectConfigProcessService.getValue("启动"),"");
    }
    public void stop() {
    }
    @OptLog(title = "程序停止")
    public void onPause() {
        s7ParamOpt.paramOpt(projectConfigProcessService.getValue("停止"),"");
        optRecordService.saveRecords("程序停止");
    }
    @OptLog(title = "程序急停")
    public void release() {
    }

    public void setAuto(boolean b) {
        optRecordService.saveRecords("手自动切换"+b);
    }
    @OptLog(title = "手动清除所有报警")
    public void cancelAlarm() {
        s7ParamOpt.paramOpt(projectConfigProcessService.getValue("报警复位"),"");
    }
    @OptLog(title = "调试模式切换")
    public void switchTest(boolean test){
    }
}
